<%@page import="com.netistate.pojo.Doc"%>
<%@page import="com.netistate.pojo.Project"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>文档</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/default.css" />
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/jquery-min.js"></script> 
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/table.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/msgbox/msgbox.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/jsp/doc/doc.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/calendar/Calendar.js"></script>
  </head>
  
  <body>
		<%-- <div class="toolbar" >
		    <a href="#" class='buttonlink txbtip' title='添加文档' onclick="addDoc()"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus.png'/>添加文档</a>  
		    <a href="#" id="queryProjectButton" class='buttonlink txbtip' onclick="queryDoc()" title='文档查询'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus.png'/>文档查询</a>  
		</div> --%>
		<div id="query_doc" name="query_doc" class="toolbar" style="display:block;overflow:hidden;">
		    <form id="query_doc_by_condition" name="query_doc_by_condition" action="query_doc_by_condition.action" method="post" >
		        <table>
		           <tr>
		                <td class="td_title" title="项目名称"><img alt="" src="${pageContext.request.contextPath}/images/common/save.gif">项目名称：</td>
		                <td class="td_title">
		                    <select id="projectName" name="projectName" style="width:100px;">
								<%	List<Project> projectList = (List<Project>)request.getSession().getAttribute("projectList");
									String queryDocProjectName = (String)request.getAttribute("queryDocProjectName");
									Project queryDocProject = (Project)request.getAttribute("queryDocProject");
									
									if("所有".equals(queryDocProjectName) || queryDocProjectName == null){%>
									<option title="所有" selected value="所有">所有</option>
									<%	for(Project p : projectList){ %>
										<option title="<%=p.getProjectName()%>" value="<%=p.getId() %>"><%=p.getProjectName()%></option>
									<% 	}
									}else{%>
									<option title="所有" selected value="所有">所有</option>
									<%	for(Project p : projectList){ 
											if(p.getId() == Integer.parseInt(queryDocProjectName)){%>
											<option title="<%=queryDocProject.getProjectName()%>" selected value="<%=queryDocProject.getId() %>"><%=queryDocProject.getProjectName()%></option>
										<%	} else { %>
											<option title="<%=p.getProjectName()%>" value="<%=p.getId() %>"><%=p.getProjectName()%></option>
									<% 		}	
										}
									} %>
		                    </select>
		                </td>
		                <td title="时间">时间：</td>
		                <td>
							<%
						        Date date = new Date();
							    SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd");
							    String endString = sdFormat.format(date);
							    Calendar calendar = Calendar.getInstance();
							    calendar.setTime(date);
							    calendar.add(Calendar.DATE,-7);
							    Date date2 = calendar.getTime();
							    String startString = sdFormat.format(date2);
							    String dayStart = (String)request.getAttribute("queryDocBegintime");
							    String dayEnd = (String)request.getAttribute("queryDocEndtime");
							    if(dayStart != null){
							         startString = dayStart;
							    }
							    if(dayEnd != null){
							         if(endString.equals(dayEnd)){
							             endString = "现在";
							         }else{
							              endString = dayEnd;
							         }
							    }else{
							        endString = "现在";
							    }
							 %>
							<input id="begintime" name="begintime" type="text" style="width:80px" onclick="MyCalendar.SetDate(this)" value="<%=startString %>" readonly="readonly" />
							</td>
							<td title="到">到</td>
							<td><input id="endtime" name="endtime" type="text" style="width:80px" onclick="MyCalendar.SetDate(this)" value="<%=endString %>" readonly="readonly" /></td>
			                <td><input type="submit" value="查询" title="查询"/></td>
		           </tr>
		        </table>
		    </form>
		</div>
		
		<div id="show_doc" style="width:100%;height:95%; overflow-y:scroll; border:1px solid;" >
			<table id="dArticleList" width="100%" border="0" cellpadding="0" cellspacing="1"  class="resizable overTd">
				<thead>
					<tr class="fixHead">
						<td  class="td1" style="cursor:pointer" width="10%">所属项目名称</td>
						<td  class="td1" style="cursor:pointer" width="10%">创建人</td>
						<td  class="td1" style="cursor:pointer" width="10%">所属服务记录名称</td>
						<td  class="td1" style="cursor:pointer" width="10%">文档名称</td>
						<td  class="td1" style="cursor:pointer" width="10%">创建时间</td>
						<td  class="td1" width="10%">下载文档</td>
					</tr>
				</thead>
				<tbody>
					<%
						List<Doc> list = new ArrayList<Doc>();
						List<Doc> docList = (List<Doc>)request.getAttribute("dList");
						if(docList == null){
							list = (List<Doc>)request.getSession().getAttribute("docList");
						}else{
							list = docList;
						}
						for(Doc d : list){
						%>
						<tr onMouseOver= "this.bgColor   =   '#cccccc '; "   onMouseOut= "this.bgColor   =   '#FFFFFF'; " >  
				       		<td title="<%=d.getProject().getProjectName() %>" align="center" class="td2 txbtip" ><%=d.getProject().getProjectName() %>&nbsp;</td>
				       		<td title="<%=d.getCreater() %>" align="center" class="td2 txbtip" ><%=d.getCreater() %>&nbsp;</td>
				       		<td title="<%=d.getProjectServices().getServiceName()%>" align="center" class="td2 txbtip" ><%=d.getProjectServices().getServiceName() %>&nbsp;</td>
				       		<td title="<%=d.getDocName() %>" align="left" class="td2 txbtip" ><%=d.getDocName() %>&nbsp;</td>
				       		<td title="<%=d.getCreatetime() %>" align="center" class="td2 txbtip" ><%=d.getCreatetime() %>&nbsp;</td>
				       		<td title="" align="center" class="td2 txbtip" >
				       			<a href="downDoc.action?docid=<%=d.getId() %>" class='buttonlink txbtip' title='下载文档' ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/down.png'/></a>
				       		</td>
						</tr>	
					  <%}%>	
					
				
				</tbody>
			</table>
		</div>
		
		
		<script type="text/javascript">
    		function addDoc(){
    			var btnHTML = "<a href=\"javascript:uploadDoc();\" class='buttonlink txbtip' title='确定'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/save.gif'/><p>确定</p></a><img src='${pageContext.request.contextPath}/images/common/shux.gif' class='split'/>";
    			PigossMsg.showWin("${pageContext.request.contextPath}/jsp/doc/addDoc.jsp","添加文档",350,280,btnHTML);
    		};
    		
    		function queryDoc(){
    			var div = document.getElementById("query_doc");
    			if(div.style.display=='none'){
		            div.style.display='block'; 
		        }else{
		           div.style.display='none'; 
		        };
    		};
    		initTableWidget('dArticleList',Array('S','S',"S",'S','S',false));
    			
    	</script>

  </body>
</html>
